import { ElMessage } from "element-plus";
export function downFile(response, title, fullFileName?) {
  const blob = new Blob([response]);
  const downloadElement = document.createElement("a");
  const href = window.URL.createObjectURL(blob);
  // 后台再header中传文件名
  downloadElement.href = href;
  downloadElement.download = fullFileName ? fullFileName : title + ".xlsx";
  document.body.appendChild(downloadElement);
  downloadElement.click();
  document.body.removeChild(downloadElement); // 下载完成移除元素
  window.URL.revokeObjectURL(href); // 释放掉blob对象
  ElMessage({
    message: "下载成功！",
    type: "success",
    duration: 5 * 1000,
  });
}
